import React, { Component } from 'react';
import { connect } from 'dva';
import { message, Modal, Pagination, Popconfirm, Button, Steps, Popover } from 'antd';
import styles from './Users.css';
import moment from 'moment';
import Factory from '../factory';
import * as datetime from '../../utils/datetime'
import dataEditCreate from '../addons/DataEdit'
import dataTableCreate from '../addons/DataTable'
import * as compDiviService from '../../services/AccountDivi';
const daoName = "TIndiDiviWorkflow";
const ButtonGroup = Button.Group;
const Step = Steps.Step;
const columns = [
    { title: '客户名称', width: 110, sorter: true, key: 'NAME', dataIndex: 'NAME', dispaly: true, filter: true },
    { title: '证件号码', width: 240, sorter: true, dataIndex: 'IDNO', key: 'IDNO', dispaly: true, filter: true },
    { title: '开户网点', width: 120, sorter: true, key: 'UTID', caption: "Organ.Name", render: data => data.Organ.Name, dispaly: true, filter: false },
    { title: '分户日期', width: 110, sorter: true, key: 'DSDT', caption: "DSDT", render: data => datetime.format(data.DSDT, "yyyy-MM-dd"), dispaly: true, filter: true },
    { title: '审批状态', width: 110, sorter: true, key: 'STEP', dataIndex: 'STEPCaption', dispaly: true, filter: true },
    { title: '客户经理1', width: 120, sorter: true, key: 'EMID1', caption: "User1.Name", render: data => data.User1.Name === "" ? "" : data.User1.Name + "(" + data.User1.No + ")", dispaly: true, filter: false },
    { title: '占比1', width: 120, sorter: true, dataIndex: 'DSVL1', key: 'DSVL1', render: data => data, dispaly: true, filter: false },
    { title: '客户经理2', width: 120, sorter: true, key: 'EMID2', caption: "User2.Name", render: data => data.User2.Name === "" ? "" : data.User2.Name + "(" + data.User2.No + ")", dispaly: true, filter: false },
    { title: '占比2', width: 120, sorter: true, dataIndex: 'DSVL2', key: 'DSVL2', render: data => data === 0 ? "" : data, dispaly: true, filter: false },
    { title: '客户经理3', width: 120, sorter: true, key: 'EMID3', caption: "User3.Name", render: data => data.User3.Name === "" ? "" : data.User3.Name + "(" + data.User3.No + ")", dispaly: true, filter: false },
    { title: '占比3', width: 120, sorter: true, dataIndex: 'DSVL3', key: 'DSVL3', render: data => data === 0 ? "" : data, dispaly: true, filter: false },
    { title: '客户经理4', width: 120, sorter: true, key: 'EMID4', caption: "User4.Name", render: data => data.User4.Name === "" ? "" : data.User4.Name + "(" + data.User4.No + ")", dispaly: true, filter: false },
    { title: '占比4', width: 120, sorter: true, dataIndex: 'DSVL4', key: 'DSVL4', render: data => data === 0 ? "" : data, dispaly: true, filter: false },
    { title: '客户经理5', width: 120, sorter: true, key: 'EMID5', caption: "User5.Name", render: data => data.User5.Name === "" ? "" : data.User5.Name + "(" + data.User5.No + ")", dispaly: true, filter: false },
    { title: '占比5', width: 120, sorter: true, dataIndex: 'DSVL5', key: 'DSVL5', render: data => data === 0 ? "" : data, dispaly: true, filter: false },
];
const controls = [
    { name: "NAME", required: true, type: 'text', label: '客户名称', min: 3, max: 30, grid: 12 / 24 },
    { name: 'IDNO', required: true, type: 'text', label: '证件号码', min: 3, max: 30, grid: 12 / 24 },
    { name: "DSDT", label: "分户日期", type: "date", grid: 12 / 24, dataType: "date" },
    {
        name: "EMID1", label: "客户经理", type: "search", grid: 12 / 24, required: false,
        fetch: { daoName: 'User', searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "ID" },
        dataType: "number", seekType: 2
    },
    {
        name: "EMID2", label: "客户经理2", type: "search", grid: 12 / 24, required: false,
        fetch: { daoName: 'User', searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "ID" },
        dataType: "number", seekType: 2
    },
    {
        name: "EMID3", label: "客户经理3", type: "search", grid: 12 / 24, required: false,
        fetch: { daoName: 'User', searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "ID" },
        dataType: "number", seekType: 2
    },
    {
        name: "EMID4", label: '客户经理4', type: "search", grid: 12 / 24, multiple: false,
        fetch: { daoName: 'User', searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "ID" },
        dataType: "number", seekType: 2
    },
    {
        name: "EMID5", label: '客户经理5', type: "search", grid: 12 / 24, multiple: false,
        fetch: { daoName: 'User', searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "ID" },
        dataType: "number", seekType: 2
    },
    { name: "DSVL1", label: '占比', type: "number", grid: 12 / 24, dataType: "number" },
    { name: "DSVL2", label: '占比2', type: "number", grid: 12 / 24, dataType: "number" },
    { name: "DSVL3", label: '占比3', type: "number", grid: 12 / 24, dataType: "number" },
    { name: "DSVL4", label: '占比4', type: "number", grid: 12 / 24, dataType: "number" },
    { name: "DSVL5", label: '占比5', type: "number", grid: 12 / 24, dataType: "number" },
    { name: "STEP", label: '审批状态', data: [{ value: '0', label: '填写申请' }, { value: '1', label: '部门主管审核' }, { value: '2', label: '综合员确认' }, { value: '3', label: '完成' }], grid: 12 / 24, type: "radio-group" },
]
const steps = [];
const EditFrom = dataEditCreate(daoName);
const DataTable = dataTableCreate(daoName);
class TIndiDiviWorkflowForm extends Component {
    constructor(props) {
        super(props);
        this.state = {
            dataChange: false,
            seachData: {},
            stepDescData: [],
            isdivi:'0',
            emid:'',
        };
        compDiviService.WorkFlowIndifetch().then(function (data) {
            for (let i = 0; i < data.length; i++) {
                let datas = {
                    title: data[i].Desc,
                    index: data[i].Step
                }
                steps.push(datas)
            }
        })
        compDiviService.GetLogin().then(
            function(data){
                this.setState.emid=data
            }
        )
    }
    componentDidMount() {
        this.props.dispatch({
            type: `TIndiDiviWorkflow/setKeyName`,
            payload: { keyName: "ID", permID: this.props.permID }
        });        
        let selectValues = ''; 
        const form = this.refs.findForm.getForm();
        form.validateFields((err, values) => {
          if (!err) {
            selectValues = values.ISDIVI;
          }
        });
        if (selectValues === 'all') {
            selectValues = '0,1,-1'
        }
        let whereItems = [];
        let WhereCauses = [];
        whereItems.push({
            FieldName: "STATE",
            Operator: "in",
            FieldValues: selectValues
        })
        WhereCauses.push({
            WhereItems: whereItems,
            RelationSign: "AND"
        })
        let seeks=WhereCauses
        this.props.dispatch({
            type: `TIndiDiviWorkflow/fetch`,
            payload: { daoName, page: 1, pageSize: 20 ,seeks}
        });
    }
    loadOptionData = (value)=> {
        if (value === 'all') {
            value = '0,1,-1'
        }
        let whereItems = [];
        let WhereCauses = []; 
        whereItems.push({
            FieldName: "STATE",
            Operator: "in",
            FieldValues: value
        })
        WhereCauses.push({
            WhereItems: whereItems,
            RelationSign: "AND"
        })
        let seeks=WhereCauses
        this.props.dispatch({
            type: `TIndiDiviWorkflow/fetch`,
            payload: { daoName, page: 1, pageSize: 20 ,seeks}
        });
    }
    showModelHandler(isAdd) {
        let key = null
        if (!isAdd) {
            const len = this.props.selectedRowKeys.length;
            if (len === 0) {
                message.info('请选择要编辑的行，如果选择了多行，则使用最后一次选择！');
                return;
            }
            key = this.props.selectedRowKeys[len - 1]
        }
        this.props.dispatch({
            type: `TIndiDiviWorkflow/openEdit`,
            payload: { key }
        });
    }
    edidOkHandler() {
        const form = this.refs.tindidiviworkflowForm.getForm()
        form.validateFields((err, values) => {
            if (!err) {
                //验证是否相对应的客户经理和分户比例都存在或者都不存在
                if ((values["EMID2"] === "" && values["DSVL2"] !== undefined && values["DSVL2"] !== 0) || (values["EMID2"] !== "" && values["DSVL2"] === undefined && values["DSVL2"] === 0)) {
                    message.error("客户经理2和对应的分户比例2必须都有或者都没有！")
                    return;
                }
                if ((values["EMID3"] === "" && values["DSVL3"] !== undefined) && values["DSVL3"] !== 0 || (values["EMID3"] !== "" && values["DSVL3"] === undefined && values["DSVL3"] === 0)) {
                    message.error("客户经理3和对应的分户比例3必须都有或者都没有！")
                    return;
                }
                if ((values["EMID4"] === "" && values["DSVL4"] !== undefined && values["DSVL4"] !== 0) || (values["EMID4"] !== "" && values["DSVL4"] === undefined && values["DSVL4"] === 0)) {
                    message.error("客户经理4和对应的分户比例4必须都有或者都没有！")
                    return;
                }
                if ((values["EMID5"] === "" && values["DSVL5"] !== undefined && values["DSVL5"] !== 0) || (values["EMID5"] !== "" && values["DSVL5"] === undefined && values["DSVL5"] === 0)) {
                    message.error("客户经理5和对应的分户比例5必须都有或者都没有！")
                    return;
                }
                //验证客户经理是否存在分配多次的情况
                if (values["EMID1"] === values["EMID2"] || values["EMID1"] === values["EMID3"] || values["EMID1"] === values["EMID4"] || values["EMID1"] === values["EMID5"]
                    || (values["EMID2"] === values["EMID3"] && (values["EMID2"] !== "" && values["EMID3"] !== ""))
                    || (values["EMID2"] === values["EMID4"] && (values["EMID2"] !== "" && values["EMID4"] !== ""))
                    || (values["EMID2"] === values["EMID5"] && (values["EMID2"] !== "" && values["EMID5"] !== ""))
                    || (values["EMID3"] === values["EMID4"] && (values["EMID4"] !== "" && values["EMID3"] !== ""))
                    || (values["EMID3"] === values["EMID5"] && (values["EMID5"] !== "" && values["EMID3"] !== ""))
                    || (values["EMID4"] === values["EMID5"] && (values["EMID4"] !== "" && values["EMID5"] !== ""))) {
                    message.error("客户经理不允许重复分配！")
                    return;
                }
                let t = `TIndiDiviWorkflow/create`
                const { keyName, record } = this.props;
                let msg = "数据添加成功！"
                if (record[keyName]) {
                    values[keyName] = record[keyName];
                    t = `TIndiDiviWorkflow/patch`
                    msg = "数据修改成功！"
                }
                controls.map((c, i) => {
                    if (c.type === 'cascader-select') {
                        let vs = values[c.name];
                        if (vs.length > 0) {
                            values[c.name] = vs[vs.length - 1];
                        } else {
                            values[c.name] = null;
                        }
                    }
                    if (c.dataType === "number") {
                        values[c.name] = values[c.name] === undefined ? 0 : Number(values[c.name])
                    } else if (c.dataType === "date" || c.dataType === "datetime") {
                        values[c.name] = !values[c.name] ? null : new Date(values[c.name])
                    } else {
                        values[c.name] = values[c.name] === undefined ? null : values[c.name]
                    }
                    if (c.multiple || c.type === 'checkbox-group') {
                        values[c.name] = values[c.name].join(',');
                    }
                })
                //验证所有客户经理分户比例只和是否等于100%
                let sumDsvl = 0;
                sumDsvl = Number(values["DSVL1"]) + Number(values["DSVL2"]) + Number(values["DSVL3"]) + Number(values["DSVL4"]) + Number(values["DSVL5"])
                if (sumDsvl !== 100) {
                    message.error("所有客户经理分户比例总和必须等于100！")
                    return;
                }
                if (values.DSVL2 === 0) {
                    values.DSVL2 = null;
                    values.EMID2 = null;
                }
                if (values.DSVL3 === 0) {
                    values.DSVL3 = null;
                    values.EMID3 = null;
                }
                if (values.DSVL4 === 0) {
                    values.DSVL4 = null;
                    values.EMID4 = null;
                }
                if (values.DSVL5 === 0) {
                    values.DSVL5 = null;
                    values.EMID5 = null;
                }
                this.state.dataChange = true;
                let dataSource = []
                let data = {
                    IDNO: values["IDNO"],
                    NAME: values["NAME"],
                    DSDT: values["DSDT"],
                    EMID1: values.EMID1,
                    DSVL1: values.DSVL1,
                    EMID2: values.EMID2,
                    DSVL2: values.DSVL2,
                    EMID3: values.EMID3,
                    DSVL3: values.DSVL3,
                    EMID4: values.EMID4,
                    DSVL4: values.DSVL4,
                    EMID5: values.EMID5,
                    DSVL5: values.DSVL5,
                    UTID:  Number(values["UTID"]),
                    SQR :  Number(this.state.emid),
                }
                dataSource.push(data)
                let istj = 'N'
                this.props.dispatch({
                    type: `TIndiDiviWorkflow/clieIndiWorkFlow`,
                    payload:{daoName,istj, dataSource}
                })                
                this.props.dispatch({
                    type: `TIndiDiviWorkflow/setRecord`,
                    payload: { record: {} },
                });
            }
        });        
        form.resetFields();
    };
    hideEditHandler() {
        const form = this.refs.tindidiviworkflowForm.getForm();
        form.resetFields();
        if (this.state.dataChange) {
            this.props.dispatch({
                type: `TIndiDiviWorkflow/reload`,
                payload: { daoName },
            });
            this.state.dataChange = false;
        }
        this.props.dispatch({
            type: `TIndiDiviWorkflow/hideEdit`
        });
    };
    seachHandler(data) {
        this.state.seachData = data;
    }
    submiAndSaveHandler() {
        const form = this.refs.tindidiviworkflowForm.getForm()
        form.validateFields((err, values) => {
            if (!err) {
                //验证是否相对应的客户经理和分户比例都存在或者都不存在
                if ((values["EMID2"] === "" && values["DSVL2"] !== undefined && values["DSVL2"] !== 0) || (values["EMID2"] !== "" && values["DSVL2"] === undefined && values["DSVL2"] === 0)) {
                    message.error("客户经理2和对应的分户比例2必须都有或者都没有！")
                    return;
                }
                if ((values["EMID3"] === "" && values["DSVL3"] !== undefined) && values["DSVL3"] !== 0 || (values["EMID3"] !== "" && values["DSVL3"] === undefined && values["DSVL3"] === 0)) {
                    message.error("客户经理3和对应的分户比例3必须都有或者都没有！")
                    return;
                }
                if ((values["EMID4"] === "" && values["DSVL4"] !== undefined && values["DSVL4"] !== 0) || (values["EMID4"] !== "" && values["DSVL4"] === undefined && values["DSVL4"] === 0)) {
                    message.error("客户经理4和对应的分户比例4必须都有或者都没有！")
                    return;
                }
                if ((values["EMID5"] === "" && values["DSVL5"] !== undefined && values["DSVL5"] !== 0) || (values["EMID5"] !== "" && values["DSVL5"] === undefined && values["DSVL5"] === 0)) {
                    message.error("客户经理5和对应的分户比例5必须都有或者都没有！")
                    return;
                }
                //验证客户经理是否存在分配多次的情况
                if (values["EMID1"] === values["EMID2"] || values["EMID1"] === values["EMID3"] || values["EMID1"] === values["EMID4"] || values["EMID1"] === values["EMID5"]
                    || (values["EMID2"] === values["EMID3"] && (values["EMID2"] !== "" && values["EMID3"] !== ""))
                    || (values["EMID2"] === values["EMID4"] && (values["EMID2"] !== "" && values["EMID4"] !== ""))
                    || (values["EMID2"] === values["EMID5"] && (values["EMID2"] !== "" && values["EMID5"] !== ""))
                    || (values["EMID3"] === values["EMID4"] && (values["EMID4"] !== "" && values["EMID3"] !== ""))
                    || (values["EMID3"] === values["EMID5"] && (values["EMID5"] !== "" && values["EMID3"] !== ""))
                    || (values["EMID4"] === values["EMID5"] && (values["EMID4"] !== "" && values["EMID5"] !== ""))) {
                    message.error("客户经理不允许重复分配！")
                    return;
                }
                let t = `TIndiDiviWorkflow/create`
                const { keyName, record } = this.props;
                let msg = "数据添加成功！"
                if (record[keyName]) {
                    values[keyName] = record[keyName];
                    t = `TIndiDiviWorkflow/patch`
                    msg = "数据修改成功！"
                }
                controls.map((c, i) => {
                    if (c.type === 'cascader-select') {
                        let vs = values[c.name];
                        if (vs.length > 0) {
                            values[c.name] = vs[vs.length - 1];
                        } else {
                            values[c.name] = null;
                        }
                    }
                    if (c.dataType === "number") {
                        values[c.name] = values[c.name] === undefined ? 0 : Number(values[c.name])
                    } else if (c.dataType === "date" || c.dataType === "datetime") {
                        values[c.name] = !values[c.name] ? null : new Date(values[c.name])
                    } else {
                        values[c.name] = values[c.name] === undefined ? null : values[c.name]
                    }
                    if (c.multiple || c.type === 'checkbox-group') {
                        values[c.name] = values[c.name].join(',');
                    }
                })
                //验证所有客户经理分户比例只和是否等于100%
                let sumDsvl = 0;
                sumDsvl = Number(values["DSVL1"]) + Number(values["DSVL2"]) + Number(values["DSVL3"]) + Number(values["DSVL4"]) + Number(values["DSVL5"])
                if (sumDsvl !== 100) {
                    message.error("所有客户经理分户比例总和必须等于100！")
                    return;
                }
                this.state.dataChange = true;
                let dataSource = []
                let data = {
                    IDNO: values["IDNO"],
                    NAME: values["NAME"],
                    DSDT: values["DSDT"],
                    EMID1: values["EMID1"],
                    DSVL1: Number(values.DSVL1),
                    EMID2: values.DSVL2 !== 0 ? values.EMID2 : null,
                    DSVL2: values.DSVL2 !== 0 ? Number(values.DSVL2) : null,
                    EMID3: values.DSVL3 !== 0 ? values.EMID3 : null,
                    DSVL3: values.DSVL3 !== 0 ? Number(values.DSVL3) : null,
                    EMID4: values.DSVL4 !== 0 ? values.EMID4 : null,
                    DSVL4: values.DSVL4 !== 0 ? Number(values.DSVL4) : null,
                    EMID5: values.DSVL5 !== 0 ? values.EMID5 : null,
                    DSVL5: values.DSVL5 !== 0 ? Number(values.DSVL5) : null,
                    UTID:  Number(values["UTID"]),
                    SQR :  Number(this.state.emid),
                }
                dataSource.push(data)
                let istj = 'Y'               
                this.props.dispatch({
                    type: `TIndiDiviWorkflow/clieIndiWorkFlow`,
                    payload:{daoName,istj, dataSource}
                })                
            }
        });        
        form.resetFields();
    }
    submitModelHandler() {
        const keys = this.props.selectedRowKeys;
        const len = keys.length;
        if (len === 0) {
            message.info('请选择要提交的审批申请！');
            return;
        }
        this.props.dispatch({
            type: `TIndiDiviWorkflow/clieIndiSubmitWorkFlow`,
            payload:{daoName,keys}
        })
    }
    rollBackModelHandler() {
        const keys = this.props.selectedRowKeys;
        const len = keys.length;
        if (len === 0) {
            message.info('请选择要退回的审批申请！');
            return;
        }
        this.props.dispatch({
            type: `TIndiDiviWorkflow/clieIndiRollWorkFlow`,
            payload:{daoName,keys}
        })
    }
    componentWillReceiveProps(nextProps) {
        if (nextProps.record.ID !== this.props.record.ID) {
            const key = nextProps.record.ID
            compDiviService.IndiWorkFlowStep({ key }
            ).then(function (data) {
                this.setState({ stepDescData: data })
            }.bind(this));
        }
    }
    render() {
        const Dot = (dot, { status, index }) => {
            let stepDesc = this.state.stepDescData[index]
            let desc = null
            if (!stepDesc) {
                stepDesc = this.state.stepDescData[index - 1]
                if (stepDesc&&stepDesc.STATE === 2) {
                    desc = '处理完成'
                }else if (stepDesc&&stepDesc.STATE === 1) {
                    desc = '正在处理'
                } else {
                    desc = '未完成'
                }
            } else {
                desc = stepDesc.CLJG
            }
            return (
                <Popover content={<span> {desc}</span>}>
                    {dot}
                </Popover>
            )

        };
        let { showEdit, record, permID, popedomTypes } = this.props        
        let data=[]
        let pTypes = popedomTypes[permID]
        if(pTypes.indexOf("2")!==-1){
        data.push({ value: '1', label: '填写申请',onClick: this.showModelHandler.bind(this,true) }, { value: '2', label: "提交", onClick: this.submitModelHandler.bind(this) })
        }
        if(pTypes.indexOf("M")!==-1){
        data.push({ value: '2', label: "同意", onClick: this.submitModelHandler.bind(this) },{value: '3', label: "不同意", onClick: this.rollBackModelHandler.bind(this)})
        }
        const controlsEdit = [
            { name: "NAME", required: true, type: 'text', label: '客户名称', min: 1, max: 30, grid: 12 / 24, placeholder: '请输入完整的客户姓名...' },
            { name: 'IDNO', required: true, type: 'text', label: '证件号码', min: 15, max: 18, grid: 12 / 24, placeholder: '请输入完整与客户姓名匹配的证件号码...' },
            {
                name: "UTID", required: true,label: "开户网点", type: "search", grid: 12 / 24, 
                fetch: { daoName: 'Organization', searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "ID", onSelect: this.seachHandler.bind(this), permID:permID },
                dataType: "number", seekType: 2
            },
            { name: "DSDT", required: true, label: "分户日期", type: "date", grid: 12 / 24, dataType: "date" },
            {
                name: "EMID1", label: "客户经理", type: "search", grid: 12 / 24, required: true,
                fetch: { daoName: 'UserSel', searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "ID", onSelect: this.seachHandler.bind(this), permID:permID },
                dataType: "number", seekType: 2
            },
            { name: "DSVL1", label: '占比', type: "number", grid: 12 / 24, dataType: "number", required: true },
            {
                name: "EMID2", label: "客户经理2", type: "search", grid: 12 / 24, required: false,
                fetch: { daoName: 'UserSel', searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "ID", onSelect: this.seachHandler.bind(this), permID:permID },
                dataType: "number", seekType: 2
            },
            { name: "DSVL2", label: '占比2', type: "number", grid: 12 / 24, dataType: "number" },
            {
                name: "EMID3", label: "客户经理3", type: "search", grid: 12 / 24, required: false,
                fetch: { daoName: 'UserSel', searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "ID", onSelect: this.seachHandler.bind(this), permID:permID },
                dataType: "number", seekType: 2
            },
            { name: "DSVL3", label: '占比3', type: "number", grid: 12 / 24, dataType: "number" },
            {
                name: "EMID4", label: '客户经理4', type: "search", grid: 12 / 24, multiple: false,
                fetch: { daoName: 'UserSel', searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "ID", onSelect: this.seachHandler.bind(this), permID:permID },
                dataType: "number", seekType: 2
            },
            { name: "DSVL4", label: '占比4', type: "number", grid: 12 / 24, dataType: "number" },
            {
                name: "EMID5", label: '客户经理5', type: "search", grid: 12 / 24, multiple: false,
                fetch: { daoName: 'UserSel', searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "ID", onSelect: this.seachHandler.bind(this), permID:permID },
                dataType: "number", seekType: 2
            },
            { name: "DSVL5", label: '占比5', type: "number", grid: 12 / 24, dataType: "number" },
        ];
        const controlsFilter = [
            { name: 'ISDIVI', required: false, type: 'select', label: '选择', grid: 4 / 24, data: [{ value: 'all', label: '全部' }, { value: '0', label: '审批中' }, { value: '1', label: '审批完成' }], layout: { labelSpan: 8, wrapperSpan: 13 }, onChange:this.loadOptionData},
            { name: 'BT', required: false, type: 'button-group', data: data, grid: 8 / 24 },
        ];
        const step = record.STEP
        const title = record.STEPCaption
        return (
            <div className={styles.normal} style={{ background: '#fff', marginTop: -16, padding: '5px 5px' }}>
                <div>
                    <div className={styles.create}>
                        <EditFrom ref="findForm" daoName={daoName} controls={controlsFilter} record={{ ISDIVI: this.state.isdivi }} selectFirst={false} clearItemMargin={true} >
                        </EditFrom>
                    </div>
                    <Modal title={title ? title : '填写申请'} width={700} visible={showEdit} onOk={this.edidOkHandler.bind(this)} onCancel={this.hideEditHandler.bind(this)}
                        footer={[
                            <Button key="close" type="ghost" onClick={this.hideEditHandler.bind(this)}>关闭</Button>,
                            <Button key="add" type="primary" onClick={this.edidOkHandler.bind(this)}>保存</Button>,
                            <Button key="submit" type="primary" onClick={this.submiAndSaveHandler.bind(this)}>保存并提交</Button>
                        ]}
                    >
                        <Steps current={step ? step : 0} progressDot={Dot}>
                            {steps.map(item => <Step key={item.index} title={item.title} />)}
                        </Steps>
                        <br />
                        <EditFrom ref="tindidiviworkflowForm" daoName={daoName} controls={controlsEdit} record={record} />
                    </Modal>
                    <DataTable ref="tindidiviworkflowTable" daoName={daoName} columns={columns} controls={controls} permID={permID} />
                </div>
            </div>
        )
    }
}

function mapStateToProps(state) {
    const { showEdit, record, selectedRowKeys, keyName } = state.TIndiDiviWorkflow;
    const { userID, orgID, pOrgID, popedomTypes } = state.menus
    return {
        userID,
        orgID,
        pOrgID,
        popedomTypes,
        showEdit,
        selectedRowKeys,
        keyName,
        record
    }
}
TIndiDiviWorkflowForm = connect(mapStateToProps)(TIndiDiviWorkflowForm)
export default TIndiDiviWorkflowForm;

let render = (props) => React.createElement(TIndiDiviWorkflowForm, props);
let f = new Factory()
f.set("TIndiDiviWorkflowForm", render)
